<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>let和var</title>
</head>
<body>
    
    <script>
        var s = 20;
        //块级作用域
        {
            //使用 var 关键字声明的变量不具备块级作用域的特性，它在 {} 外依然能被访问到
            var s = 10;
        }
        console.log(s);//10


        let m = 200;
        {
            let m = 100;
        }
        console.log(m);//200

        {
            // 没有使用var或者let,那么这个变量就是全局变量
            x = 300;
        }
        console.log(x);
    </script>

</body>
</html>